﻿<!-- #layout name=noMenu --sideType='domain'-->
<div id="app" v-clock>
  <div class="page-header">
    <h1 class="title">Domain management</h1>
  </div>
  <div class="navbar navbar-default">
    <div class="container-fluid">
      <a class="btn green navbar-btn" @click.stop="onCreate">
        <span>Add a domain</span>
        <i class="fa fa-plus"></i>
      </a>

      <!--<a
        k-if="kooboosetting.IsLocal = false"
        class="btn green navbar-btn"
        :href="registerPageUrl"
        ><span>Register a domain</span>
        <i class="fa fa-plus"></i>
      </a>-->

      <a
        v-if="tableDataSelected.length > 0"
        @click.stop="onDelete"
        class="btn red navbar-btn"
        >Delete</a
      >
    </div>
  </div>

  <kb-table
    :show-select="true"
    :data="tableData"
    :selected.sync="tableDataSelected"
  >
    <kb-table-column :label="Kooboo.text.site.domain.name">
      <template v-slot="row">
        <a
          :href="Kooboo.Route.Get(Kooboo.Route.Domain.DomainBinding, {
                        id: row.id
                    })"
          @click.stop=""
          style="cursor: pointer"
          >{{row.domainName}}</a
        >
      </template>
    </kb-table-column>
    <kb-table-column :label="Kooboo.text.site.domain.expires">
      <template v-slot="row">
        <span class="label label-sm label-warning">{{row.expires}}</span>
      </template>
    </kb-table-column>
    <kb-table-column :label="Kooboo.text.site.domain.records">
      <template v-slot="row">
        {{row.records}}
      </template>
    </kb-table-column>
    <kb-table-column :label="Kooboo.text.site.domain.site">
      <template v-slot="row">
        <span class="badge blue">{{row.records}}</span>
      </template>
    </kb-table-column>
    <kb-table-column :label="Kooboo.text.site.domain.email">
      <template v-slot="row">
        <span
          :class="row.useEmail?'label badge blue':'label label-sm label-default'"
        >
          {{row.emails?row.emails:Kooboo.text.common.no}}</span
        >
      </template>
    </kb-table-column>
  </kb-table>

  <div
    class="modal fade"
    data-backdrop="static"
    data-keyboard="false"
    v-kb-modal="showCreateDialog"
  >
    <kb-dialog>
      <kb-dialog-header :close-handle="onDialogCancel">
        <h4 class="modal-title">New local domain</h4>
      </kb-dialog-header>

      <kb-dialog-content>
        <div class="note note-info" k-if="kooboosetting.IsLocal = true">
          <h4 class="title">You are running in local mode</h4>
          <!-- prettier-ignore -->
          <p>You need to configure DNS records. For Windows desktop users, a mapping of your website domain to 127.0.0.1 may be created on your system host file</p>
        </div>
        <div
          v-if="serverInfo"
          class="note note-info"
          k-if="kooboosetting.IsLocal = false"
        >
          <h4 class="title">Adding a domain to your account</h4>
          <!-- prettier-ignore -->
          <p>Use below DNS server, all DNS records will be created automatically for you.</p>
          <dl
            v-if="serverInfo.dnsServers"
            v-for="item in serverInfo.dnsServers"
          >
            <!--<dt data-bind="text: 'DNS ' + ($index() + 1)"></dt>-->
            <dd>{{item}}</dd>
          </dl>
          <!-- prettier-ignore -->
          <p>Or create your domain  wildcard CNAME record to below domain.</p>
          <p>{{serverInfo.cName}}</p>
          <!-- prettier-ignore -->
          <p>Or create your domain wildcard A record to below IP address. This is not recommeneded because we may change our IP</p>
          <p>{{serverInfo.ipAddress}}</p>
        </div>

        <div class="form-horizontal">
          <div class="form-group">
            <label class="col-md-2 control-label" for="DomainName"
              >Domain</label
            >
            <div class="col-md-10">
              <input
                v-kb-hint="domainValidateModel.msg"
                v-model="domain"
                class="form-control"
                placeholder="kooboolocal.com"
                type="text"
              />
            </div>
          </div>
        </div>
      </kb-dialog-content>
      <kb-dialog-footer>
        <button @click="onAdd" class="btn green">Add</button>
        <button @click="onDialogCancel" class="btn gray">Cancel</button>
      </kb-dialog-footer>
    </kb-dialog>
  </div>
</div>

<script>
  (function() {
    Kooboo.loadJS([
      "/_Admin/Scripts/components/kbTable.js",
      "/_Admin/Scripts/components/kbDialog.js"
    ]);
  })();
</script>
<script src="/_Admin/View/Domains.js"></script>
